//
//  GravityViewController.m
//  Camera
//
//  Created by gml on 2019/1/18.
//  Copyright © 2019年 gml. All rights reserved.
//

#import "GravityViewController.h"

@interface GravityViewController ()
@property (nonatomic,strong) UIDynamicAnimator *animator;
@property (nonatomic,weak) UIView *redView;
@end

@implementation GravityViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    UIView  *red = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
    red.backgroundColor = [UIColor redColor];
    self.redView = red;
    [self.view addSubview:red];
    self.animator = [[UIDynamicAnimator alloc] initWithReferenceView:self.view];
    UIGravityBehavior* gravityBeahvior = [[UIGravityBehavior alloc] initWithItems:@[self.redView]];
    // 设置下落速度
    [gravityBeahvior setGravityDirection:CGVectorMake(0.0f,0.05f)]; //property changed after printing of the book
    // 偏移方向
//    [gravityBeahvior setAngle:0.5 magnitude:0.1];
    [self.animator addBehavior:gravityBeahvior];
    
}



@end
